import { defineStore } from 'pinia'
import { fetchData } from '@/utils/fetch'
import { API_URLS } from '@/utils/api'

export const useStore = defineStore('main', {
  state: () => ({
    count: 0,
    userData: null
  }),
  getters: {
    doubleCount: (state) => state.count * 2
  },
  actions: {
    increment() {
      this.count++
    },
    async loadUserData() {
      try {
        this.userData = await fetchData(API_URLS.getUser, {}, 500)
      } catch (error) {
        console.error('Error loading user data:', error)
      }
    }
  }
}) 